3 // Copyright (C) 2005 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
32 // Permission to use, copy, modify, sell, and distribute this software
33 // is hereby granted without fee, provided that the above copyright
34 // notice appears in all copies, and that both that copyright notice and
35 // this permission notice appear in supporting documentation. None of
36 // the above authors, nor IBM Haifa Research Laboratories, make any
37 // representation about the suitability of this software for any
38 // purpose. It is provided "as is" without express or implied warranty.
41 * @file resize_fn_imps.hpp
42 * Contains implementations of gp_ht_map_'s resize related functions.
47 PB_ASSOC_CLASS_C_DEC::
50 if (!my_resize_base::is_resize_needed())
54 do_resize(my_resize_base::get_new_size(m_num_e, m_num_used_e));
55 while (my_resize_base::is_resize_needed());
62 PB_ASSOC_CLASS_C_DEC::
63 do_resize_if_needed_no_throw()
65 if (!my_resize_base::is_resize_needed())
71 do_resize(my_resize_base::get_new_size(m_num_e, m_num_used_e));
72 while (my_resize_base::is_resize_needed());
77 PB_ASSOC_DBG_ONLY(assert_valid();)
82 PB_ASSOC_CLASS_C_DEC::
83 do_resize(size_type new_size)
85 #ifdef PB_ASSOC_BASIC_REGRESSION
86 throw_prob_adjustor adjust(m_num_e);
87 #endif // #ifdef PB_ASSOC_BASIC_REGRESSION
89 PB_ASSOC_DBG_ONLY(assert_valid();)
91 const size_type old_size = m_num_e;
93 entry_array a_entries_resized = NULL;
95 my_ranged_probe_fn_base::notify_resized(new_size);
97 // Following line might throw an exception.
101 a_entries_resized = s_entry_allocator.allocate(new_size);
105 my_ranged_probe_fn_base::notify_resized(old_size);
112 for (size_type i = 0; i < m_num_e; ++i)
113 a_entries_resized[i].m_stat = (entry_status)EMPTY_ENTRY_STATUS;
117 resize_imp(a_entries_resized, old_size);
121 erase_all_valid_entries(a_entries_resized, new_size);
125 s_entry_allocator.deallocate(a_entries_resized, new_size);
127 my_ranged_probe_fn_base::notify_resized(old_size);
132 // At this point no exceptions can be thrown.
134 PB_ASSOC_DBG_ONLY(assert_entry_array_valid(a_entries_resized, my_hash_traits_base::s_store_hash_indicator);)
136 Resize_Policy::notify_resized(new_size);
138 erase_all_valid_entries(m_a_entries, old_size);
140 s_entry_allocator.deallocate(m_a_entries, old_size);
142 m_a_entries = a_entries_resized;
144 PB_ASSOC_DBG_ONLY(assert_valid();)
149 PB_ASSOC_CLASS_C_DEC::
150 resize_imp(entry_array a_entries_resized, size_type old_size)
152 for (size_type pos = 0; pos < old_size; ++pos)
153 if (m_a_entries[pos].m_stat == VALID_ENTRY_STATUS)
154 resize_imp_reassign(m_a_entries + pos, a_entries_resized, my_hash_traits_base::s_store_hash_indicator);
157 #include <ext/pb_assoc/detail/gp_ht_map_/resize_no_store_hash_fn_imps.hpp>
158 #include <ext/pb_assoc/detail/gp_ht_map_/resize_store_hash_fn_imps.hpp>